package com.ihmp.business;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ihmp.dao.HotelDAO;
import com.ihmp.dao.ProductInRoomDAO;
import com.ihmp.model.Tproductinrooms;

@Service
@Transactional
public class ProductInRoomServiceImpl implements ProductInRoomService {
	
	@Autowired
	private ProductInRoomDAO productInRoomDAO;
	private HotelDAO hotelDAO;
	
	@Transactional 
	public void saveOrUpdateProductInRoom(Tproductinrooms tproductinroom) {
		productInRoomDAO.saveOrUpdateProductInRoom(tproductinroom);
	}

	public void deleteProductInRoom(Tproductinrooms tproductinroom) {
		productInRoomDAO.deleteProductInRoom(tproductinroom);
	}

	public Tproductinrooms getProductInRoom(Integer id) {
		return productInRoomDAO.getProductInRoom(id);
	}

	public List<Tproductinrooms> listProductInRoom() {
		return productInRoomDAO.listProductInRooms();
	}

	@Override
	public void addHotel(Tproductinrooms productInRoom,Integer hotelId) { // id is hotelId
		productInRoom.setHotel(hotelDAO.get(hotelId));		
	}
	
}
